﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Medianamik.Globalization.Utilities
{
    public static class ResourceExtensions
    {
        public static string ToSqlEnum(this IEnumerable<string> collection)
        {
            var count = collection.Count();

            if(count < 2)
                throw new ApplicationException("Collection should contains more than one item.");

            var sqlBuilder = new StringBuilder();
            var format = "{0}";

            for (var i = 0; i < count; i++)
            {
                if (i == 1)
                    format = "," + format;

                sqlBuilder.AppendFormat(format, collection.ElementAt(i));
            }

            return sqlBuilder.ToString();
        }
    }
}
